<vdr-page-block>
    <vdr-action-bar>
        <vdr-ab-left> </vdr-ab-left>
        <vdr-ab-right>
            <vdr-action-bar-items locationId="tax-rate-list" />
            <a
                class="btn btn-primary"
                *vdrIfPermissions="['CreateSettings', 'CreateTaxRate']"
                [routerLink]="['./', 'create']"
            >
                <clr-icon shape="plus"></clr-icon>
                {{ 'settings.create-new-tax-rate' | translate }}
            </a>
            <vdr-action-bar-dropdown-menu locationId="tax-rate-list" />
        </vdr-ab-right>
    </vdr-action-bar>
</vdr-page-block>
<vdr-data-table-2
    [id]="dataTableListId"
    [items]="items$ | async"
    [itemsPerPage]="itemsPerPage$ | async"
    [totalItems]="totalItems$ | async"
    [currentPage]="currentPage$ | async"
    [filters]="filters"
    (pageChange)="setPageNumber($event)"
    (itemsPerPageChange)="setItemsPerPage($event)"
    (visibleColumnsChange)="setVisibleColumns($event)"
>
    <vdr-bulk-action-menu
        locationId="tax-rate-list"
        [hostComponent]="this"
        [selectionManager]="selectionManager"
    />
    <vdr-dt2-search
        [searchTermControl]="searchTermControl"
        [searchTermPlaceholder]="'catalog.filter-by-name' | translate"
    />
    <vdr-dt2-column [heading]="'common.id' | translate" id="id" [hiddenByDefault]="true">
        <ng-template let-taxRate="item">
            {{ taxRate.id }}
        </ng-template>
    </vdr-dt2-column>
    <vdr-dt2-column
        [heading]="'common.created-at' | translate" id="created-at"
        [hiddenByDefault]="true"
        [sort]="sorts.get('createdAt')"
    >
        <ng-template let-taxRate="item">
            {{ taxRate.createdAt | localeDate : 'short' }}
        </ng-template>
    </vdr-dt2-column>
    <vdr-dt2-column
        [heading]="'common.updated-at' | translate" id="updated-at"
        [hiddenByDefault]="true"
        [sort]="sorts.get('updatedAt')"
    >
        <ng-template let-taxRate="item">
            {{ taxRate.updatedAt | localeDate : 'short' }}
        </ng-template>
    </vdr-dt2-column>
    <vdr-dt2-column [heading]="'common.name' | translate" id="name" [optional]="false" [sort]="sorts.get('name')">
        <ng-template let-taxRate="item">
            <a class="button-ghost" [routerLink]="['./', taxRate.id]"
                ><span>{{ taxRate.name }}</span>
                <clr-icon shape="arrow right"></clr-icon>
            </a>
        </ng-template>
    </vdr-dt2-column>
    <vdr-dt2-column [heading]="'settings.tax-category' | translate" id="tax-category">
        <ng-template let-taxRate="item">
            {{ taxRate.category.name }}
        </ng-template>
    </vdr-dt2-column>
    <vdr-dt2-column [heading]="'settings.zone' | translate" id="zone">
        <ng-template let-taxRate="item">
            {{ taxRate.zone.name }}
        </ng-template>
    </vdr-dt2-column>
    <vdr-dt2-column [heading]="'customer.customer-group' | translate" id="customer-group" [hiddenByDefault]="true">
        <ng-template let-taxRate="item">
            {{ taxRate.customerGroup?.name }}
        </ng-template>
    </vdr-dt2-column>
    <vdr-dt2-column [heading]="'settings.tax-rate' | translate" id="tax-rate" [sort]="sorts.get('value')">
        <ng-template let-taxRate="item"> {{ taxRate.value }}% </ng-template>
    </vdr-dt2-column>
    <vdr-dt2-column [heading]="'common.enabled' | translate" id="enabled">
        <ng-template let-taxRate="item">
            <vdr-chip *ngIf="taxRate.enabled" colorType="success">{{
                'common.enabled' | translate
            }}</vdr-chip>
            <vdr-chip *ngIf="!taxRate.enabled" colorType="warning">{{
                'common.disabled' | translate
            }}</vdr-chip>
        </ng-template>
    </vdr-dt2-column>
    <vdr-dt2-custom-field-column *ngFor="let customField of customFields" [customField]="customField" [sorts]="sorts" />
</vdr-data-table-2>
